package com.snail.clouds.framework.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snail.clouds.framework.entity.CloudAccount;
import com.snail.clouds.framework.mapper.CloudAccountMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 云存储账户服务实现类
 */
@Service
public class CloudAccountService extends ServiceImpl<CloudAccountMapper, CloudAccount> {
    
    /**
     * 根据用户ID获取云存储账户列表
     * @param userId 用户ID
     * @return 云存储账户列表
     */
    public List<CloudAccount> getByUserId(Long userId) {
        return this.list(
            new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<CloudAccount>()
                .eq("user_id", userId)
                .eq("deleted", 0)
        );
    }
    
    /**
     * 根据用户ID和云类型获取云存储账户
     * @param userId 用户ID
     * @param cloudType 云类型
     * @return 云存储账户
     */
    public CloudAccount getByUserIdAndCloudType(Long userId, String cloudType) {
        return this.getOne(
            new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<CloudAccount>()
                .eq("user_id", userId)
                .eq("cloud_type", cloudType)
                .eq("deleted", 0)
        );
    }
}